<?php

use yii\db\Migration;

class m170930_012704_create_classroom_group_raletion extends Migration
{
    private function createDbs(){
        $dbs = [];
        $dbs_info =\Yii::$app->params['db'];
        foreach($dbs_info as $k=>$v){
            $dbs[$k] = \Yii::createObject($v);
        }
        return $dbs;
    }

    public function safeUp()
    {
        $dbs = $this->createDbs();
        foreach ($dbs as $v) {
            $this->db = $v;
            $this->createTable('{{%classroom_group_relation}}',[
                'classroom_group_id' => $this->integer()->defaultValue(0).' COMMENT \'教室组id\'',
                'classroom_id' => $this->integer()->defaultValue(0).' COMMENT \'教室id\'',
            ]);
        }
    }

    public function safeDown()
    {
        $dbs = $this->createDbs();
        foreach($dbs as $v){
            $this->db = $v;
            $this->dropTable('{{%classroom_group_relation}}');
        }
    }
}
